package com.ruoyi.detail.contreoller;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.detail.domain.SessionDetail;
import com.ruoyi.detail.domain.SessionDetailDto;
import com.ruoyi.detail.service.ISessionDetailService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @program: RuoYi-Vue-master
 * @description:
 * @author: xgw
 * @create: 2025-01-07 17:21
 **/


@RestController
@RequestMapping("/system/sessionDetail")
public class SessionDetailController extends BaseController {

    @Autowired
    private ISessionDetailService iSessionDetailService;

    /**
    * @Description: 查询出所有的会话细节
    * @Param: []
    * @return: com.ruoyi.common.core.domain.AjaxResult
    * @Author: xgw
    * @Date: 2025/1/13
    */
    @GetMapping("/selectAllSessionDetail")
    public AjaxResult selectAllSessionDetail() {
        //获取全部的session_detail
        return iSessionDetailService.selectAllSessionDetail();
    }

    /**
    * @Description: 插入会话细节
    * @Param: [sessionDetail]
    * @return: com.ruoyi.common.core.domain.AjaxResult
    * @Author: xgw
    * @Date: 2025/1/13
    */
    @PostMapping("/insertSessionDetail")
    public AjaxResult insertSessionDetail(@RequestBody SessionDetail sessionDetail) {
        return iSessionDetailService.insertSessionDetail(sessionDetail);
    }

    /**
     * 更新会话细节
     * @param sessionDetail
     * @return
     */
    @PostMapping("/updateSessionDetailById")
    public AjaxResult updateSessionDetailById(@RequestBody SessionDetail sessionDetail) {
        iSessionDetailService.selectSessionDetailById(sessionDetail.getId());
        return iSessionDetailService.updateSessionDetailById(sessionDetail);
    }
    /**
    * @Description: 删除会话细节
    * @Param: [id]
    * @return: com.ruoyi.common.core.domain.AjaxResult
    * @Author: xgw
    * @Date: 2025/1/13
    */
    @GetMapping("/deleteSessionDetailById/{id}")
    public AjaxResult deleteSessionDetailById(@PathVariable("id") Integer id) {
        return iSessionDetailService.deleteSessionDetailById(id);
    }

    /**
    * @Description: 根据会话id，查询出会话详情
    * @Param: [sessionId]
    * @return: com.ruoyi.common.core.domain.AjaxResult
    * @Author: xgw
    * @Date: 2025/1/13
    */
    @GetMapping("/selectSessionDetailByTimestamp/{sessionId}")
    public AjaxResult selectSessionDetailByTimestamp(@PathVariable("sessionId")Integer sessionId){
        return iSessionDetailService.selectSessionDetailByTimestamp(sessionId);
    }

    /**
     * 查询出某个会话的对话细节,根据id
     * @param id
     * @return
     */
    @GetMapping("/selectSessionDetailById/{id}")
    public AjaxResult selectSessionDetailById(@PathVariable("id") Integer id) {
        return iSessionDetailService.selectSessionDetailById(id);
    }
    /**
    * @Description: 动态查询
    * @Param: [sessionDetailDto]
    * @return: com.ruoyi.common.core.domain.AjaxResult
    * @Author: xgw
    * @Date: 2025/1/13
    */
    @PostMapping("/dynamicSelectSessionDetail")
    public AjaxResult dynamicSelectSessionDetail(@RequestBody SessionDetailDto sessionDetailDto) {

        return iSessionDetailService.dynamicSelectSessionDetail(
                sessionDetailDto.getUsername(), sessionDetailDto.getSessionId(),
                sessionDetailDto.getStartTime(), sessionDetailDto.getEndTime());
    }
}
